<?php
/*
 * @Author: zeyudada
 * @Date: 2022-02-13 21:13:35
 * @LastEditTime: 2022-03-17 09:35:01
 * @Description: 
 * @Q Q: zeyunb@vip.qq.com(1776299529)
 * @E-mail: admin@zeyudada.cn
 * 
 * Copyright (c) 2022 by zeyudada, All Rights Reserved. 
 */
include('head.php');
if ($config['rank'] == '关') die('<!DOCTYPE html><html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>run</title>
</head><body onload="setTimeout(close,3000)">
排行榜暂未开启，请联系管理员开启！
<script>function close(){ parent.layui.admin.closeCurrentTab(); } </script>
</body>');

$top = rank(10);
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $config['sitename']; ?>排行榜</title>
</head>

<body>
    <div class="main">
        <div class="title">
            <img src="/logo.png" alt="" />
            <div><?php echo $config['sitename']; ?> - 平均分排行榜<br>
            <h6>tips: 分数在排序时是精确的，展示的已经四舍五入</h6></div>
        </div>
        <div class="list-box">
            <div class="list">
                <div class="number">1</div>
                <div class="user">
                    <img src="/assets/images/1.png" class="head-url" alt="" />
                    <div>
                        <p class="good"><?php echo $top[1]['name'] ?></p>
                        <p class="jk-num">
                            <span>状元</span>答题<?php echo $top[1]['num']; ?>次
                        </p>
                    </div>
                </div>
                <div class="km"><?php echo round($top[1]['score']); ?></div>
            </div>
            <div class="list">
                <div class="number">2</div>
                <div class="user">
                    <img src="/assets/images/2.png" class="head-url" alt="" />
                    <div>
                        <p class="good"><?php echo $top[2]['name'] ?></p>
                        <p class="jk-num">
                            <span>榜眼</span>答题<?php echo $top[2]['num']; ?>次
                        </p>
                    </div>
                </div>
                <div class="km"><?php echo round($top[2]['score']); ?></div>
            </div>
            <div class="list">
                <div class="number">3</div>
                <div class="user">
                    <img src="/assets/images/3.png" class="head-url" alt="" />
                    <div>
                        <p class="good"><?php echo $top[3]['name'] ?></p>
                        <p class="jk-num">
                            <span>探花</span>答题<?php echo $top[3]['num']; ?>次
                        </p>
                    </div>
                </div>
                <div class="km"><?php echo round($top[3]['score']); ?></div>
            </div>
            <?php
            $i = 4;

            foreach ($top as $value) {
                # 把剩下的遍历出来
                if(empty($top[$i])) break;
                $score = $top[$i]['score'];
                echo <<<EOF
                <div class="list">
                <div class="number">$i</div>
                <div class="user">
                    <img src="/assets/images/user.svg" class="head-url" alt="" />
                    <div>
                        <p class="good">{$top[$i]['name']}</p>
                        <p class="jk-num">答题{$top[$i]['num']}次
                        </p>
                    </div>
                </div>
                <div class="km">{$score}</div>
            </div>
EOF;
                $i++;
            }
            ?>
            

        </div>
    </div>

</body>

</html>

<style>
    * {
        margin: 0;
        padding: 0;
    }

    .main {
        background-color: rgb(255, 228, 17);
        width: auto;
        min-height: 100vh;
        overflow: hidden;
        padding: 20px;
        box-sizing: border-box;
        color: #fff;
    }

    .main .title {
        width: 100%;
        text-align: center;
        font-size: 20px;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main .title img {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }

    .main .list-box {
        margin: 25px;
        padding: 20px 0;
        background-color: rgba(255, 255, 255, 0.5);
        border-radius: 16px;
    }

    .main .list-box .list {
        display: flex;
        align-items: center;
        padding: 20px 40px;
        color: #666;
        box-sizing: border-box;
    }

    .main .list-box .list .number {
        width: 25px;
        text-align: left;
        color: #888;
        font-size: 14px;
    }

    .main .list-box .list .user {
        display: flex;
        align-items: center;
        position: relative;
    }

    .main .list-box .list .user .head-url {
        display: block;
        width: 50px;
        height: 50px;
        margin-right: 20px;
        border-radius: 50%;
    }

    .main .list-box .list .user .level {
        display: block;
        position: absolute;
        top: -7.5px;
        left: -7.5px;
        width: 25px;
        z-index: 10;
    }

    .main .list-box .list .user .good {
        font-weight: bold;
    }

    .main .list-box .list .user div {
        min-width: 0;
        flex: 1;


    }

    .main .list-box .list .user div .jk-num {
        margin-top: 10px;
        font-size: 10px;
        color: rgb(190, 190, 190);


    }

    .main .list-box .list .user div span {
        margin-right: 10px;
        color: rgb(238, 76, 76);
    }

    .main .list-box .list .km {
        margin-left: auto;
        font-size: 14px;
    }
</style>